package indi.gao;

import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.BaseFont;
import org.xhtmlrenderer.pdf.ITextFontResolver;
import org.xhtmlrenderer.pdf.ITextRenderer;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * <p>Description:</p>
 * <p>Copyright: Copyright (c)2019$</p>
 * <p>Company: Tope</p>
 * <P>Created Date :2019$-09$-26$</P>
 * <P>@version 1.0</P>
 */
public class HtmlToPdf {
    public static void main(String[] args) throws IOException, DocumentException {
        //指定PDF的存放路径
        String outputFile = "/Users/gaolei/file/personalCode/GLUnitTest/HtmlToPdf/src/main/resources/file/test.pdf";
        OutputStream os = new FileOutputStream(outputFile);
        ITextRenderer renderer = new ITextRenderer();
        ITextFontResolver fontResolver = renderer.getFontResolver();
        //指定字体。为了支持中文字体
        fontResolver.addFont("/Users/gaolei/file/personalCode/GLUnitTest/HtmlToPdf/src/main/resources/file/arial-unicode.woff.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

        StringBuffer html = new StringBuffer();

        html.append("<!DOCTYPE html>" +
                "<html>\n" +
                "<head>\n" +
                "  <title></title>\n" +
                "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n" +
                "  <style type=\"text/css\">\n" +
                "    a {text-decoration: none}\n" +
                "  </style>\n" +
                "</head>\n" +
                "<body text=\"#000000\" link=\"#000000\" alink=\"#000000\" vlink=\"#000000\">\n" +
                "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n" +
                "<tr><td width=\"50%\">&nbsp;</td><td align=\"center\">\n" +
                "\n" +
                "<a name=\"JR_PAGE_ANCHOR_0_1\"></a>\n" +
                "<table class=\"jrPage\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"empty-cells: show; width: 911px; border-collapse: collapse; background-color: white;\">\n" +
                "<tr valign=\"top\" style=\"height:0\">\n" +
                "<td style=\"width:46px\"></td>\n" +
                "<td style=\"width:1px\"></td>\n" +
                "<td style=\"width:35px\"></td>\n" +
                "<td style=\"width:19px\"></td>\n" +
                "<td style=\"width:1px\"></td>\n" +
                "<td style=\"width:20px\"></td>\n" +
                "<td style=\"width:9px\"></td>\n" +
                "<td style=\"width:16px\"></td>\n" +
                "<td style=\"width:15px\"></td>\n" +
                "<td style=\"width:7px\"></td>\n" +
                "<td style=\"width:33px\"></td>\n" +
                "<td style=\"width:31px\"></td>\n" +
                "<td style=\"width:11px\"></td>\n" +
                "<td style=\"width:4px\"></td>\n" +
                "<td style=\"width:60px\"></td>\n" +
                "<td style=\"width:7px\"></td>\n" +
                "<td style=\"width:21px\"></td>\n" +
                "<td style=\"width:2px\"></td>\n" +
                "<td style=\"width:38px\"></td>\n" +
                "<td style=\"width:7px\"></td>\n" +
                "<td style=\"width:11px\"></td>\n" +
                "<td style=\"width:19px\"></td>\n" +
                "<td style=\"width:42px\"></td>\n" +
                "<td style=\"width:10px\"></td>\n" +
                "<td style=\"width:49px\"></td>\n" +
                "<td style=\"width:1px\"></td>\n" +
                "<td style=\"width:5px\"></td>\n" +
                "<td style=\"width:4px\"></td>\n" +
                "<td style=\"width:16px\"></td>\n" +
                "<td style=\"width:51px\"></td>\n" +
                "<td style=\"width:1px\"></td>\n" +
                "<td style=\"width:41px\"></td>\n" +
                "<td style=\"width:33px\"></td>\n" +
                "<td style=\"width:2px\"></td>\n" +
                "<td style=\"width:4px\"></td>\n" +
                "<td style=\"width:79px\"></td>\n" +
                "<td style=\"width:3px\"></td>\n" +
                "<td style=\"width:39px\"></td>\n" +
                "<td style=\"width:60px\"></td>\n" +
                "<td style=\"width:5px\"></td>\n" +
                "<td style=\"width:3px\"></td>\n" +
                "<td style=\"width:50px\"></td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:44px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"39\" style=\"text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 20px; line-height: 1.140625; font-weight: bold;\">测试专用供应商</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:19px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"39\" style=\"text-indent: 0px;  vertical-align: bottom;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 16px; line-height: 1.140625; font-weight: bold;\">送货单</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:1px\">\n" +
                "<td colspan=\"42\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:19px\">\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"3\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">门店:</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"20\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">测试专用采购商</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"5\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">订货日期:</span></td>\n" +
                "<td colspan=\"4\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">2021/01/29</span></td>\n" +
                "<td colspan=\"2\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: right;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">到货日期：</span></td>\n" +
                "<td colspan=\"4\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">2021/01/30</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:1px\">\n" +
                "<td>\n" +
                "</td>\n" +
                "<td>\n" +
                "</td>\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"5\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:1px\">\n" +
                "<td colspan=\"42\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:20px\">\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"3\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">单号:</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"35\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">4257414</span></td>\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:20px\">\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"3\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">收货人:</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "<td colspan=\"4\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">测试姓名</span></td>\n" +
                "<td colspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: right;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">电话:</span></td>\n" +
                "<td colspan=\"6\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">18022222222</span></td>\n" +
                "<td colspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: right;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">地址:</span></td>\n" +
                "<td colspan=\"22\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">广东省东莞市市辖区东直门22层</span></td>\n" +
                "<td>\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:1px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"6\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">配送开始时间:</span></td>\n" +
                "<td colspan=\"25\">\n" +
                "</td>\n" +
                "<td colspan=\"5\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">货到付款</span></td>\n" +
                "<td colspan=\"4\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:19px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"8\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">2021/01/30 06:00</span></td>\n" +
                "<td colspan=\"6\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: right;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">配送结束时间:</span></td>\n" +
                "<td colspan=\"8\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">2021/01/30 12:00</span></td>\n" +
                "<td colspan=\"3\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: right;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">支付方式:</span></td>\n" +
                "<td colspan=\"4\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:1px\">\n" +
                "<td colspan=\"16\">\n" +
                "</td>\n" +
                "<td colspan=\"8\">\n" +
                "</td>\n" +
                "<td colspan=\"9\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:19px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"5\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">业务员名称:</span></td>\n" +
                "<td colspan=\"7\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">张元</span></td>\n" +
                "<td colspan=\"4\" rowspan=\"2\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">业务员电话:</span></td>\n" +
                "<td colspan=\"10\" style=\"text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">17792907690</span></td>\n" +
                "<td colspan=\"14\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:1px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"7\">\n" +
                "</td>\n" +
                "<td colspan=\"24\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:4px\">\n" +
                "<td colspan=\"42\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:19px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">编号</span></td>\n" +
                "<td colspan=\"9\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">品项名称</span></td>\n" +
                "<td colspan=\"4\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">规格</span></td>\n" +
                "<td colspan=\"5\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">单位</span></td>\n" +
                "<td colspan=\"2\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">订货数量</span></td>\n" +
                "<td colspan=\"5\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">发货数量</span></td>\n" +
                "<td colspan=\"2\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">单价</span></td>\n" +
                "<td colspan=\"5\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">金额</span></td>\n" +
                "<td colspan=\"4\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">备注</span></td>\n" +
                "<td colspan=\"3\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:19px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">1</span></td>\n" +
                "<td colspan=\"9\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">水晶头</span></td>\n" +
                "<td colspan=\"4\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">高品质的</span></td>\n" +
                "<td colspan=\"5\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">件</span></td>\n" +
                "<td colspan=\"2\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">1</span></td>\n" +
                "<td colspan=\"5\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">1</span></td>\n" +
                "<td colspan=\"2\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">1</span></td>\n" +
                "<td colspan=\"5\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">1</span></td>\n" +
                "<td colspan=\"4\" style=\"border: 1px solid #000000; text-indent: 0px;  vertical-align: middle;text-align: left;\">\n" +
                "</td>\n" +
                "<td colspan=\"3\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:17px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"32\" style=\"border-top: 1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid #000000; text-indent: 0px; text-align: right;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">总金额：</span></td>\n" +
                "<td colspan=\"5\" style=\"border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-right: 1px solid #000000; text-indent: 0px; text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 14px; line-height: 1.140625; font-weight: bold;\">1</span></td>\n" +
                "<td colspan=\"3\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:265px\">\n" +
                "<td colspan=\"42\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:22px\">\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"4\" style=\"text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 16px; line-height: 1.140625; font-weight: bold;\">周转箱：</span></td>\n" +
                "<td colspan=\"4\">\n" +
                "</td>\n" +
                "<td colspan=\"3\" style=\"text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 16px; line-height: 1.140625; font-weight: bold;\">司机：</span></td>\n" +
                "<td colspan=\"2\">\n" +
                "</td>\n" +
                "<td colspan=\"5\" style=\"text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 16px; line-height: 1.140625; font-weight: bold;\">库管：</span></td>\n" +
                "<td colspan=\"4\">\n" +
                "</td>\n" +
                "<td colspan=\"5\" style=\"text-indent: 0px;  vertical-align: middle;text-align: center;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 16px; line-height: 1.140625; font-weight: bold;\">验货人：</span></td>\n" +
                "<td colspan=\"13\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:10px\">\n" +
                "<td colspan=\"27\">\n" +
                "</td>\n" +
                "<td colspan=\"5\" style=\"text-indent: 0px; text-align: right;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 7px; line-height: 1.140625; font-weight: bold;\">第 1 页 / </span></td>\n" +
                "<td colspan=\"4\" rowspan=\"2\" style=\"text-indent: 0px; text-align: left;\">\n" +
                "<span style=\"font-family: 黑体; color: #000000; font-size: 7px; line-height: 1.140625; font-weight: bold;\">共 1 页</span></td>\n" +
                "<td colspan=\"6\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "<tr valign=\"top\" style=\"height:1px\">\n" +
                "<td colspan=\"32\">\n" +
                "</td>\n" +
                "<td colspan=\"6\">\n" +
                "</td>\n" +
                "</tr>\n" +
                "</table>\n" +
                "\n" +
                "<![if IE]>\n" +
                "<script>\n" +
                "var links = document.querySelectorAll('link.jrWebFont');\n" +
                "setTimeout(function(){ if (links) { for (var i = 0; i < links.length; i++) { links.item(i).href = links.item(i).href; } } }, 0);\n" +
                "</script>\n" +
                "<![endif]>\n" +
                "</td><td width=\"50%\">&nbsp;</td></tr>\n" +
                "</table>\n" +
                "</body>\n" +
                "</html>\n");
        renderer.setDocumentFromString(html.toString());
        // 解决图片的相对路径问题
        // renderer.getSharedContext().setBaseURL("file:///F:/workSpace/UtilTest/HtmlToPdf/src/main/resources/file");
        renderer.layout();
        renderer.createPDF(os);
        renderer.finishPDF();
        renderer = null;
        os.close();
    }
}

